package net.slteam.base;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;


/**
 * 通用时间戳对象
 * @author calm
 */
@MappedSuperclass
public class BaseBeanWithTime implements Serializable,IBaseBean {

    @Column(columnDefinition = "timestamp(3) comment '生成时间' default CURRENT_TIMESTAMP(3)")
    @Schema
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date created;

    @Column(columnDefinition = "timestamp(3) comment '更新时间' default CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)")
    @Schema
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updated;

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    @Override
    public String toString() {
        return "BaseBeanWithTime{" +
                "created=" + created +
                ", updated=" + updated +
                "} " + super.toString();
    }
}
